/****************************************************************

this file is part of Music Practice Audio Player
Copyright (C)2012 Serhii Ratsyborynskyi (ratz@live.ru)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

******************************************************************/

#include "TrackController.hpp"
#include <QDebug>

TrackController::TrackController(int id, QString name, QWidget *parent) :
    QWidget(parent), mId(id)
{
    initGrafic(name);
}

void TrackController::slotMute(bool mute)
{
    emit signalMute(mId, mute);
}

void TrackController::slotSolo(bool solo)
{
    emit signalSolo(mId, solo);
}

void TrackController::slotVolume(int volume)
{
    emit signalVolume(mId, volume);
}



void TrackController::initGrafic(const QString & name)
{
    QGroupBox   * pGroupBox = new QGroupBox(name, this);
    QPushButton * pSoloButton = new QPushButton( "Solo", this );
    pSoloButton->setCheckable(true);
    QPushButton * pMuteButton = new QPushButton( "Mute", this );
    pMuteButton->setCheckable(true);
    QSlider * pSlider = new QSlider(Qt::Horizontal, this );

    pSlider->setValue(80);


    QHBoxLayout * pHLboxInner = new QHBoxLayout(pGroupBox);

    pHLboxInner->addWidget(pSlider);
    pHLboxInner->addWidget(pSoloButton);
    pHLboxInner->addWidget(pMuteButton);

    setLayout(new QHBoxLayout(this));
    layout()->addWidget(pGroupBox);

    // Mute button connection
    connect(pMuteButton, SIGNAL(toggled(bool)), this, SLOT(slotMute(bool)) );
    // Solo button connection
    connect(pSoloButton, SIGNAL(toggled(bool)), this, SLOT(slotSolo(bool)) );
    // Volume slider
    connect(pSlider, SIGNAL(valueChanged(int)), this, SLOT(slotVolume(int)) );
}
